package com.ruoyi.project.gxgw_modules.warning.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.gxgw_modules.warning.domain.Warning;
import com.ruoyi.project.gxgw_modules.warning.service.IWarningService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 设备异常 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-01-25
 */
@Controller
@RequestMapping("/gxgw_modules/warning")
public class WarningController extends BaseController
{
    private String prefix = "gxgw_modules/warning";
	
	@Autowired
	private IWarningService warningService;
	
	@RequiresPermissions("gxgw_modules:warning:view")
	@GetMapping()
	public String warning()
	{
	    return prefix + "/warning";
	}
	
	/**
	 * 查询设备异常列表
	 */
	@RequiresPermissions("gxgw_modules:warning:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(Warning warning)
	{
		startPage();
        List<Warning> list = warningService.selectWarningList(warning);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出设备异常列表
	 */
	@RequiresPermissions("gxgw_modules:warning:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Warning warning)
    {
    	List<Warning> list = warningService.selectWarningList(warning);
        ExcelUtil<Warning> util = new ExcelUtil<Warning>(Warning.class);
        return util.exportExcel(list, "warning");
    }
	
	/**
	 * 新增设备异常
	 */
//	@GetMapping("/add")
//	public String add()
//	{
//	    return prefix + "/add";
//	}
	
	/**
	 * 新增保存设备异常
	 */
//	@RequiresPermissions("gxgw_modules:warning:add")
//	@Log(title = "设备异常", businessType = BusinessType.INSERT)
//	@PostMapping("/add")
//	@ResponseBody
//	public AjaxResult addSave(Warning warning)
//	{
//		return toAjax(warningService.insertWarning(warning));
//	}

	/**
	 * 修改设备异常
	 */
//	@GetMapping("/edit/{warnId}")
//	public String edit(@PathVariable("warnId") Integer warnId, ModelMap mmap)
//	{
//		Warning warning = warningService.selectWarningById(warnId);
//		mmap.put("warning", warning);
//	    return prefix + "/edit";
//	}
	
	/**
	 * 修改保存设备异常
	 */
//	@RequiresPermissions("gxgw_modules:warning:edit")
//	@Log(title = "设备异常", businessType = BusinessType.UPDATE)
//	@PostMapping("/edit")
//	@ResponseBody
//	public AjaxResult editSave(Warning warning)
//	{
//		return toAjax(warningService.updateWarning(warning));
//	}
	
	/**
	 * 删除设备异常
	 */
	@RequiresPermissions("gxgw_modules:warning:remove")
	@Log(title = "设备异常", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(warningService.deleteWarningByIds(ids));
	}
	
}
